package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.CheckNewsDTO;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.model.wemedia.dtos.wmNewsListDTO;
import com.heima.wemedia.service.WmNewsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author itlxc
 * @since 2024-07-26
 */
@RestController
@RequestMapping("/api/v1/news")
@RequiredArgsConstructor
@Slf4j
@Api(tags = "app端内容管理")
public class WmNewsController {

    private final WmNewsService wmNewsService;


    /**
     * 内容列表查询
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("内容列表查询")
    public ResponseResult findAll(@RequestBody WmNewsPageReqDto dto) {
        log.info("内容列表查询:{}", dto);
        return wmNewsService.findAll(dto);
    }

    /**
     * 文章发布
     * @param dto
     * @return
     */
    @PostMapping("/submit")
    @ApiOperation("文章发布")
    public ResponseResult submitNews(@RequestBody WmNewsDto dto) {
        log.info("文章发布：{}", dto);
        return wmNewsService.submitNews(dto);
    }

    /**
     * 文章上下架
     * @param dto
     * @return
     */
    @PostMapping("/down_or_up")
    public ResponseResult downOrUp(@RequestBody WmNewsDto dto){
        log.info("文章上下架：{}", dto);
        return wmNewsService.downOrUp(dto);
    }

    /**
     * 查询文章列表
     * @param wmNewsListDTO
     * @return
     */
    @PostMapping("list_vo")
    public ResponseResult wmNewsList(@RequestBody wmNewsListDTO wmNewsListDTO) {
        log.info("查询文章列表：{}", wmNewsListDTO);
        return wmNewsService.wmNewsList(wmNewsListDTO);
    }

    @PostMapping("/auth_fail")
    public ResponseResult checkAuthFail(@RequestBody CheckNewsDTO dto) {
        log.info("文章驳回：{}", dto);
        return wmNewsService.checkAuthFail(dto);
    }

    @PostMapping("/auth_pass")
    public ResponseResult checkAuthPass(@RequestBody CheckNewsDTO dto) {
        log.info("文章审核通过：{}", dto);
        return wmNewsService.checkAuthPass(dto);
    }

}
